//
//  EvaluateVC.m
//  phmall
//
//  Created by admin on 2017/10/9.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "EvaluateVC.h"
#import "OrderEvaluationView.h"
#import "OrderCell.h"
#import "EvaluateText.h"
#import "ScoringView.h"
@interface EvaluateVC ()<UITableViewDelegate,UITableViewDataSource>{
    UIView *headerView;
}
@property(strong,nonatomic)UITableView *myTableview;
@end

@implementation EvaluateVC
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.myTableview];
    [self.myTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(0);
        make.left.right.equalTo(self.view).priorityHigh();
        make.bottom.equalTo(self.view).with.offset(0).priorityHigh();
    }];
    headerView=[UIView new];
    headerView.backgroundColor=[UIColor groupTableViewBackgroundColor];
    //轮播图
    
    OrderEvaluationView* evaluate=[[OrderEvaluationView alloc]init];
    [headerView addSubview:evaluate];
    [evaluate  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(headerView);
        make.top.equalTo(headerView).offset(0);
        make.height.offset(44);
        
    }];
    [evaluate layoutIfNeeded];
    
    UILabel *line=[UILabel new];
    line.backgroundColor=[UIColor groupTableViewBackgroundColor];
    [headerView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(evaluate.mas_bottom).offset(0);
        make.left.equalTo(headerView).with.offset(0);
        make.right.equalTo(headerView).with.offset(0);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(headerView.mas_bottom).offset(0);
    }];
    
    //添加webview前计算一次高度
    CGFloat height = [headerView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    CGRect frame = headerView.bounds;
    frame.size.height = height;
    headerView.frame = frame;
    [self.myTableview setTableHeaderView:headerView];
    [headerView layoutIfNeeded];
    // Do any additional setup after loading the view.
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 330;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.01;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 330)];
    view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView *back=[[UIView alloc]init];
    back.backgroundColor=[UIColor whiteColor];
    [view addSubview:back];
    [back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(view);
        make.left.equalTo(view).offset(0);
        make.right.equalTo(view).offset(0);
        make.height.offset(160);
    }];
    
    EvaluateText *textView=[[EvaluateText alloc]init];
    textView.placeholder=@"商品满足您的需求吗？在这里留下你的想法吧~~~";
    [back addSubview:textView];
    [textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(back);
        make.left.equalTo(back).offset(10);
        make.right.equalTo(back).offset(-10);
        make.height.offset(160);
    }];
    
    ScoringView* scoring=[[ScoringView alloc]init];
    [view addSubview:scoring];
    [scoring  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(view);
        make.top.equalTo(textView.mas_bottom).offset(10);
        make.bottom.equalTo(view);
    }];
    
    return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view=[[UIView alloc]init];
    view.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    OrderEvaluationView* evaluate=[[OrderEvaluationView alloc]init];
    [view addSubview:evaluate];
    [evaluate  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(view);
        make.top.equalTo(view).offset(10);
        make.bottom.equalTo(view.mas_bottom);
    }];
    return nil;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    OrderCell *cell=[OrderCell theShareCellWithTableView:tableView];
//    OrderModel *model=self.orderList[indexPath.section];
//    NSMutableArray *data=model.goods_list;
//    GoodsListModel *goodsModel=data[indexPath.row];
//    cell.model=goodsModel;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //分割线补全
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
//MARK:-GETTER
- (UITableView *)myTableview{
    if (!_myTableview) {
        _myTableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _myTableview.delegate = self;
        _myTableview.dataSource = self;
        _myTableview.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _myTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTableview.showsVerticalScrollIndicator=NO;
        //        _myTableview.emptyDataSetSource=self;
        //        _myTableview.emptyDataSetDelegate=self;
        _myTableview.scrollEnabled = YES;
    }
    return _myTableview;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
